package com.guanwu.net.protocal;

import java.util.Map;

/**
 * @author guanwu
 * @created on 2022-01-08 23:58:39
 **/
public class RequestCommand {
    private int code;
    public static final int RPC_TYPE = 0; // request command
    public static final int ONEWAY_RPC = 1; //rpc
    //区分是普通RPC，还是单边RPC
    private int type = 0;
    //版本
    private int version;
    private int flag;
    //自定义传输文本
    private String remark;
    //请求自定义扩展信息
    private Map<String, String> extFields;
    private transient byte[] body;

    public void markResponseType() {
        int bits = 1 << RPC_TYPE;
        this.type |= bits;
    }

    public boolean isResponseType() {
        int bits = 1 << RPC_TYPE;
        return (this.type & bits) == bits;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public int getVersion() {
        return version;
    }

    public void setVersion(int version) {
        this.version = version;
    }

    public int getFlag() {
        return flag;
    }

    public void setFlag(int flag) {
        this.flag = flag;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public Map<String, String> getExtFields() {
        return extFields;
    }

    public void setExtFields(Map<String, String> extFields) {
        this.extFields = extFields;
    }

    public byte[] getBody() {
        return body;
    }

    public void setBody(byte[] body) {
        this.body = body;
    }
}
